<template>
  <el-dialog title="小程序详情及设置" :visible.sync="visible" :close-on-click-modal="false">
    <el-tabs class="content-tabs" value="first" type="border-card">
      <el-tab-pane label="基本信息" name="first">
        <el-form :model="dataForm" @keyup.enter.native="dataFormSubmit()" label-width="100px">
          <!-- <el-form-item label="版权" size="mini">
            <el-radio-group v-model="dataForm.copyright">
              <el-radio :label="0">禁止</el-radio>
              <el-radio :label="1">允许</el-radio>
            </el-radio-group>
          </el-form-item> -->
          <el-form-item label="appid">
            {{info.appid}}
          </el-form-item>
          <el-form-item label="首页码">
            {{info.homecode}}
          </el-form-item>
          <el-form-item label="备注">
            <el-input
              type="textarea"
              :rows="3"
              v-model="dataForm.remark">
            </el-input>
          </el-form-item>
        </el-form>
      </el-tab-pane>
      <!-- <el-tab-pane label="授权域名" name="second">
          授权域名
      </el-tab-pane> -->
    </el-tabs>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import API from '@/api'
export default {
  data () {
    return {
      visible: false,
      info: {
        appid: '',
        homecode: ''
      },
      dataForm: {
        id: 0,
        copyright: 0,
        remark: ''
      }
    }
  },
  methods: {
    init (id) {
      this.dataForm.id = id || 0
      this.visible = true
      console.log(this.dataForm.id)
      API.miniuserproduct.info(this.dataForm.id).then(({data}) => {
        if (data && data.code === 0) {
          this.visible = true
          this.info.appid = data.miniUserProduct.appid
          this.info.homecode = data.miniUserProduct.homecode
          this.dataForm.copyright = data.miniUserProduct.copyright
          this.dataForm.remark = data.miniUserProduct.remark
        }
      })
    },
    // 表单提交
    dataFormSubmit () {
      console.log('表单提交')
    }
  }
}
</script>
